<?php

class ErrorController extends Zend_Controller_Action {
	public function errorAction() {
		$errors = $this->_getParam('error_handler');

		switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
            	// 404 error - controller or action not found
                $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
                // Clear previous content
                $this->getResponse()->clearBody();
                $errorMsg = '<h1>Error!</h1><p>The page you requested was not found.</p>';
                $this->view->content = $errorMsg;
                break;
            default:
                // application error
                $this->_helper->layout->disableLayout();
                $this->_helper->viewRenderer->setNoRender();
                App_ExceptionFormatter::display($errors);
                break;
        }
	}
}